package main

import (
    "fmt"
    "strings"
    "unicode"
)

// 判断字符串是否是回文串
func isPalindrome(s string) bool {
    var cleaned strings.Builder

    // 清理字符串：移除非字母数字字符并转换为小写
    for _, char := range s {
        if unicode.IsLetter(char) || unicode.IsDigit(char) {
            cleaned.WriteRune(unicode.ToLower(char))
        }
    }

    cleanedStr := cleaned.String()

    // 双指针法判断是否是回文
    left, right := 0, len(cleanedStr)-1
    for left < right {
        if cleanedStr[left] != cleanedStr[right] {
            return false
        }
        left++
        right--
    }
    return true
}

func main() {
    // 测试用例
    testCases := []string{
        "A man, a plan, a canal: Panama",
        "race a car",
        " ",
        "0P",
    }

    for _, s := range testCases {
        result := isPalindrome(s)
        fmt.Printf("输入: %q, 是否是回文串: %v\n", s, result)
    }
}